package com.bangcommunity.bbframe.springredis;

import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SessionCallback;
import org.springframework.data.redis.core.script.RedisScript;
import org.springframework.data.redis.serializer.RedisSerializer;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * Created by tanghc
 */
public interface ISpringRedisCache<V> extends IRedisRepository<String, V> {

    public RedisTemplate<String, V> getRedisTemplate();

    void setIncr(String key, Long value, long timeout, TimeUnit unit);

    void setString(String key, String value, long timeout, TimeUnit unit);

    void setIncr(String key, Long value);

    void setString(String key, String value);

    Long getIncr(String key);

    String getString(String key);

    public boolean setNX(final String key, final V value);

    Long lPushAll(String key, V... values);

    Long rPushAll(String key, V... values);

    Long zRemByRange(String key, long start, long end);

    Long zRemByScore(String key, double start, double end);

    public <T> T execute(final RedisScript<T> script, final List<String> keys, final Object... args);

    public <T> T execute(final RedisScript<T> script, final RedisSerializer<?> argsSerializer,
            final RedisSerializer<T> resultSerializer, final List<String> keys, final Object... args);

    <T> T execute(RedisCallback<T> action);

    <T> T execute(SessionCallback<T> session);

    String wrapPrefix(String key);
    public void destroy();
}
